The ifconfig Command
The ifconfig
command is a network interface configuration utility that is used to configure and manage network interfaces on Unix-like operating systems. It is a powerful tool that can be used to perform a variety of tasks, such as:
- Listing network interfaces.
- Viewing the configuration of a network interface.
- Enabling/disabling a network interface.
- Changing the IP address of a network interface.
- Configuring routing tables.
Syntax
The basic syntax for the ifconfig
command is as follows:
ifconfig [interface] [options]
The interface argument is the name of the network interface that you want to configure or manage. If you do not specify an interface, the ifconfig
command will list all of the network interfaces on the system.
The options argument is a list of options that can be used to modify the behavior of the ifconfig
command.
Examples
List all of the network interfaces on the system:
ifconfig
Display the configuration of the network interface eth0
:
ifconfig eth0
Enable the network interface eth0
:
ifconfig eth0 up
Disable the network interface eth0
:
ifconfig eth0 down
Change the IP address of the network interface eth0
to 192.168.1.100:
ifconfig eth0 192.168.1.100
Add a route to the network 192.168.0.0/24 through the gateway 192.168.1.1
:
ifconfig eth0 add 192.168.0.0/24 via 192.168.1.1
Options
The ifconfig
command has a number of options that can be used to modify its behavior. Some of the most common options are:
-
up: Enable the network interface.
-
down: Disable the network interface.
-
netmask: Set the netmask for the network interface.
-
broadcast: Set the broadcast address for the network interface.
-
gateway: Set the default gateway for the network interface.
-
add: Add a route to the routing table.
-
del: Delete a route from the routing table.
For more information on the ifconfig
command and its options, please see the man page for ifconfig
.
With gencmd
gencmd
can help you quickly get the options for the ifconfig
gencmd -c ifconfig change the ip address of a network interface
- ifconfig <interface> <inet> <address>/<netmask>
- ifconfig <interface> <inet addr> <netmask>
- ifconfig <interface> <new_ip_address>